import { useUserStore } from '@/store/modules/user'
import { isString } from '@/utils/is'

/**
 * 判断按钮权限
 *
 * @param   {Any}  userPermissionList  用户按钮权限，string/array
 * @return  {Boolean}  存在权限返回true，否则返回false
 */
export default function (userPermission) {
  const { permission } = useUserStore()
  let userPer = userPermission

  if (!userPer) return false
  if (isString(userPer)) userPer = [userPer]

  return userPer.some((e) => permission && permission.includes(e))
}
